package org.arch_learn.rpc.rmi.service;

import org.arch_learn.rpc.rmi.pojo.User;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Map;

public class UserService extends UnicastRemoteObject implements IUserService {
    private static Map<Integer, User> users;

    static {
        users = new HashMap<Integer, User>() {{
            put(1, new User(1, "张三"));
            put(2, new User(2, "李四"));
        }};
    }

    public UserService() throws RemoteException {
    }

    @Override
    public User findUserById(Integer id) throws RemoteException {
        return users.get(id);
    }
}
